home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / easyx / data1.cab / Example_Files / Tutorial / Tutorial1 / Form1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-11-03  |  3.3 KB  |  113 lines

  1. VERSION 5.00
  2. Object = "{5A65A9C0-089F-11D2-88AD-0000B45C4CF6}#1.0#0"; "EASYX.OCX"
  3. Begin VB.Form Form1 
  4.    Caption         =   "Form1"
  5.    ClientHeight    =   3195
  6.    ClientLeft      =   60
  7.    ClientTop       =   345
  8.    ClientWidth     =   4680
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   3195
  11.    ScaleWidth      =   4680
  12.    StartUpPosition =   3  'Windows Default
  13.    Begin PROJECTEXLibCtl.EasyX EasyX1 
  14.       Left            =   1320
  15.       OleObjectBlob   =   "Form1.frx":0000
  16.       Top             =   840
  17.    End
  18. Attribute VB_Name = "Form1"
  19. Attribute VB_GlobalNameSpace = False
  20. Attribute VB_Creatable = False
  21. Attribute VB_PredeclaredId = True
  22. Attribute VB_Exposed = False
  23. Option Explicit
  24. Dim SurfaceYellow As Long
  25. Dim SurfaceBlack As Long
  26. Dim SpriteYellow As Long
  27. Dim SpriteBlack As Long
  28. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  29. On Error GoTo Fejl
  30. If KeyCode = vbKeyEscape Then
  31.     EasyX1.EndDirectX
  32.     Unload Me
  33. End If
  34. If KeyCode = vbKeyA Then
  35.     'fill the surface first
  36.     EasyX1.FillSurface 255, EX_PRIMARYSURFACE
  37.     'draw the sprite
  38.     EasyX1.DrawSprite 100, 100, 100, 50, SpriteBlack
  39.     'flip it
  40.     EasyX1.FlipSurface
  41. End If
  42. If KeyCode = vbKeyB Then
  43.     'fill the surface first
  44.     EasyX1.FillSurface 255, EX_PRIMARYSURFACE
  45.     'draw the sprite
  46.     EasyX1.DrawSprite 100, 100, 100, 50, SpriteYellow
  47.     'flip it
  48.     EasyX1.FlipSurface
  49. End If
  50. If KeyCode = vbKeyC Then
  51.     'fill the surface first
  52.     EasyX1.FillSurface 255, EX_PRIMARYSURFACE
  53.     'draw the sprite
  54.     EasyX1.DrawSprite 100, 100, 100, 50, SpriteBlack
  55.     EasyX1.DrawSprite 0, 0, 200, 100, SpriteYellow
  56.     'flip it
  57.     EasyX1.FlipSurface
  58. End If
  59. If KeyCode = vbKeyD Then
  60.     'fill the surface first
  61.     EasyX1.FillSurface 30, EX_PRIMARYSURFACE
  62.     'flip it
  63.     EasyX1.FlipSurface
  64. End If
  65. Exit Sub
  66. Fejl:
  67.     Debug.Print Err.Number & Err.Description
  68.     Unload Me
  69. End Sub
  70. Private Sub Form_Load()
  71. Dim rt As Long
  72. Dim AppPath As String
  73. ''Do NOT forget this
  74. EasyX1.Window = Me.hWnd
  75. rt = EasyX1.InitDirectDraw(320, 200, 8)
  76. If rt <> EX_OK Then
  77.     'try a different format
  78.     rt = EasyX1.InitDirectDraw(640, 480, 8)
  79.     If rt <> EX_OK Then 'hmmm wrong again..try another
  80.         rt = EasyX1.InitDirectDraw(800, 600, 8)
  81.         
  82.         If rt <> EX_OK Then 'that
  83. s it..no more..
  84.             MsgBox "Direct draw could not initializee", vbOKOnly, "Failure"
  85.             Exit Sub
  86.         End If
  87.     End If
  88. End If
  89. 'load the surfaces
  90. AppPath = App.Path & "\"
  91. SurfaceYellow = EasyX1.LoadBitmapFile(AppPath & "easyx.bmp", -1)
  92. If SurfaceYellow < 0 Then
  93.     MsgBox "Could not load graphics" & vbCrLf & "Make sure that the graphic files are there", vbOKOnly, "Failure"
  94.     EasyX1.EndDirectX
  95.     Unload Me
  96.     Exit Sub
  97. End If
  98. SurfaceBlack = EasyX1.LoadBitmapFile(AppPath & "easyx1.bmp", -1)
  99. If SurfaceBlack < 0 Then
  100.     MsgBox "Could not load graphics" & vbCrLf & "Make sure that the graphic files are there", vbOKOnly, "Failure"
  101.     EasyX1.EndDirectX
  102.     Unload Me
  103.     Exit Sub
  104. End If
  105. 'make the sprites
  106. SpriteYellow = EasyX1.MakeSprite(0, 0, 100, 50, SurfaceYellow)
  107. SpriteBlack = EasyX1.MakeSprite(0, 0, 100, 50, SurfaceBlack)
  108. 'color the background black
  109. EasyX1.FillSurface 0, EX_PRIMARYSURFACE
  110. 'and flip the color to make it visible
  111. EasyX1.FlipSurface
  112. End Sub
  113.